package com.woniuxy.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.Menu;
import com.woniuxy.entity.Perm;
import com.woniuxy.entity.PermDto;
import com.woniuxy.service.MenuService;
import com.woniuxy.service.PermService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO(用一句话描述这个类的作用)
 * @Author 18452
 * @Date 2021/4/26 18:42
 */

@Controller
@CrossOrigin
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    /*@RequestMapping("select")
    @ResponseBody
    public PageInfo<Perm> select(@RequestBody PermDto permDto){
        System.out.println("-------"+permDto);
        PageInfo<Perm> permPageInfo = permService.select(permDto);
        return permPageInfo;
    }*/
    @RequestMapping("/selectMenu")
    @ResponseBody
    public List<Menu> selectMenu(){
        List<Menu> menuList = menuService.selectMenu();
        System.out.println("-------"+ menuList);
        return menuList;
    }
    @RequestMapping("/selectOne/{id}")
    @ResponseBody
    public List<Menu> selectOne(@PathVariable int id){

        List<Menu> menuList = menuService.selectOne(id);
        System.out.println("@RequestBody int id:" + menuList);
        return menuList;
    }
    @RequestMapping("/selectFatherMenu")
    @ResponseBody
    public List<Menu> selectFatherMenu(){
        List<Menu> menuList = menuService.selectFatherMenu();
        return menuList;
    }
    @RequestMapping("/updateMenu")
    @ResponseBody
    public String updateMenu(@RequestBody Menu menu){
        System.out.println("-----------" + menu);
        String result = menuService.update(menu);
        return result;
    }
    @RequestMapping("/saveMenu")
    @ResponseBody
    public String update(@RequestBody Menu menu){
        System.out.println("-------"+menu);
        String result = menuService.insert(menu);
        return result;
    }
    @RequestMapping("/deleteMenu/{id}")
    @ResponseBody
    public String delete(@PathVariable int id){
        String result = menuService.delete(id);
        return result;
    }
    /*
    @RequestMapping("delete")
    @ResponseBody
    public String delete(int id){
        String result = permService.delete(id);
        return result;
    }*/
}
